home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000098_icon-group-sender _Thu May 13 14:46:25 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  4KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 17 May 1993 07:43:38 MST
  2. Received: by owl.cs.arizona.edu; Mon, 17 May 1993 07:43:37 MST
  3. Date: 13 May 93 14:46:25 GMT
  4. From: agate!howland.reston.ans.net!ux1.cso.uiuc.edu!uchinews!ellis!goer@ucbvax.Berkeley.EDU  (Richard L. Goerwitz)
  5. Organization: University of Chicago
  6. Subject: Re: Icon vs Prolog, docs, availability ?
  7. Message-Id: <1993May13.144625.16769@midway.uchicago.edu>
  8. References: <borbor-130593120939@129.194.82.105>
  9. Sender: icon-group-request@cs.arizona.edu
  10. To: icon-group@cs.arizona.edu
  11. Status: R
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. borbor@divsun.unige.ch (Boris Borcic) writes:
  15. >
  16. >For instance, it is at times desirable to constrain the 
  17. >search for further solutions in a way that depends on the
  18. >solutions already found. IMHO, the declarative leaning of Prolog's
  19. >backtracking makes this difficult and unnatural to program.
  20. >Does Icon let me do this naturally ?
  21.  
  22. This is the main advantage of Icon, and its disadvantage (rela-
  23. tive to Prolog).  Icon is not an attempt at instantiating first-
  24. order predicate logic.  It is not pure in this respect.  Yet it
  25. includes all of the mechanisms one would need to do this:  It
  26. has control and optional data backtracking, and can handle prob-
  27. lems without any notion of assignment.  You can write programs
  28. that function solely by something analogous to term unification,
  29. and the like.
  30.  
  31. The fact that Icon is not pure makes it easier to cheat, if you
  32. are so inclined.  I.e. there are operators that limit the amount
  33. of backtracking.  For example, if I take a string like "hellolo,"
  34. and ask for the position of every "l" in it, I might say:
  35.  
  36.     "hellolo" ? every write(find("l"))
  37.  
  38. The question mark says "we're going to work on the preceding
  39. string."  This expression will write 3, 4, and 6.  But let's say
  40. we only want two results.  We can cheat:
  41.  
  42.     "hellolo" ? every write(find("l")) \ 2
  43.  
  44. Now if you want to check earlier results, Icon has a more Algol-
  45. ish exterior than Prolog.  You can assign variables explicitly,
  46. much as you would in Pascal:
  47.  
  48.     "hellolo" ? {
  49.         every i := find("l") do {
  50.         if i = 6 then next
  51.         else write(i)
  52.         }
  53.     }
  54.  
  55. This will have the same effect as saying
  56.  
  57.     "hellolo" ? every write(find("l")) \ 2
  58.  
  59. I.e. it will write only 3 and 4, but not 6.
  60.  
  61. Personally, my favorite part of Icon is string scanning.  It is,
  62. in a way, syntactic sugar.  But there are aspects of it that make
  63. it uniquely elegant.  The ? marker sets up a string as the object
  64. of a scanning expression, and you can then do lots of neat things
  65. to that string.  The scanning expression is a kind of control
  66. structure, so you can break out of it or return, and its environ-
  67. ments are handled correctly.  There's not much point in explaining
  68. it, though, until you've looked at a textbook and tried it out.
  69. If you had a whiff of Snobol, I guess it's probably broadly simi-
  70. lar.
  71.  
  72. >Some FAQs : Is there an Icon Bible ? Internet on-line docs ?
  73. >Public domain implementations ? For what systems ?
  74.  
  75. The main archive site is cs.arizona.edu, and you'll find lots of
  76. interesting PD implementations there for most popular systems, and
  77. porting instructions for the unpopular ones :-).  The main text-
  78. book is Griswold & Griswold _The Icon Programming Language_ (Pren-
  79. tice Hall, c. 1989).
  80.  
  81. Enjoy.  If you have X or OS/2, try enabling the visual interface.
  82. If you're using UNIX and are interested in a bit of experimentation,
  83. try the (still a bit experimental) compiler as well.
  84.  
  85. -- 
  86.  
  87.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  88.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  89.